3.178 \(\int \frac {\sin ^2(x)}{a+b \sin (x)} \, dx\)

Optimal. Leaf size=61 \[ \frac {2 a^2 \tan ^{-1}\left (\frac {a \tan \left (\frac {x}{2}\right )+b}{\sqrt {a^2-b^2}}\right )}{b^2 \sqrt {a^2-b^2}}-\frac {a x}{b^2}-\frac {\cos (x)}{b} \]

[Out]

-a*x/b^2-cos(x)/b+2*a^2*arctan((b+a*tan(1/2*x))/(a^2-b^2)^(1/2))/b^2/(a^2-b^2)^(1/2)

________________________________________________________________________________________

Rubi [A]  time = 0.10, antiderivative size = 61, normalized size of antiderivative = 1.00, number of steps used = 6, number of rules used = 6, integrand size = 13, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.462, Rules used = {2746, 12, 2735, 2660, 618, 204} \[ \frac {2 a^2 \tan ^{-1}\left (\frac {a \tan \left (\frac {x}{2}\right )+b}{\sqrt {a^2-b^2}}\right )}{b^2 \sqrt {a^2-b^2}}-\frac {a x}{b^2}-\frac {\cos (x)}{b} \]

Antiderivative was successfully verified.

[In]

Int[Sin[x]^2/(a + b*Sin[x]),x]

[Out]

-((a*x)/b^2) + (2*a^2*ArcTan[(b + a*Tan[x/2])/Sqrt[a^2 - b^2]])/(b^2*Sqrt[a^2 - b^2]) - Cos[x]/b

Rule 12

Int[(a_)*(u_), x_Symbol] :> Dist[a, Int[u, x], x] /; FreeQ[a, x] &&  !MatchQ[u, (b_)*(v_) /; FreeQ[b, x]]

Rule 204

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> -Simp[ArcTan[(Rt[-b, 2]*x)/Rt[-a, 2]]/(Rt[-a, 2]*Rt[-b, 2]), x] /
; FreeQ[{a, b}, x] && PosQ[a/b] && (LtQ[a, 0] || LtQ[b, 0])

Rule 618

Int[((a_.) + (b_.)*(x_) + (c_.)*(x_)^2)^(-1), x_Symbol] :> Dist[-2, Subst[Int[1/Simp[b^2 - 4*a*c - x^2, x], x]
, x, b + 2*c*x], x] /; FreeQ[{a, b, c}, x] && NeQ[b^2 - 4*a*c, 0]

Rule 2660

Int[((a_) + (b_.)*sin[(c_.) + (d_.)*(x_)])^(-1), x_Symbol] :> With[{e = FreeFactors[Tan[(c + d*x)/2], x]}, Dis
t[(2*e)/d, Subst[Int[1/(a + 2*b*e*x + a*e^2*x^2), x], x, Tan[(c + d*x)/2]/e], x]] /; FreeQ[{a, b, c, d}, x] &&
 NeQ[a^2 - b^2, 0]

Rule 2735

Int[((a_.) + (b_.)*sin[(e_.) + (f_.)*(x_)])/((c_.) + (d_.)*sin[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(b*x)/d
, x] - Dist[(b*c - a*d)/d, Int[1/(c + d*Sin[e + f*x]), x], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d
, 0]

Rule 2746

Int[((a_.) + (b_.)*sin[(e_.) + (f_.)*(x_)])^2/((c_.) + (d_.)*sin[(e_.) + (f_.)*(x_)]), x_Symbol] :> -Simp[(b^2
*Cos[e + f*x])/(d*f), x] + Dist[1/d, Int[Simp[a^2*d - b*(b*c - 2*a*d)*Sin[e + f*x], x]/(c + d*Sin[e + f*x]), x
], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d, 0]

Rubi steps

\begin {align*} \int \frac {\sin ^2(x)}{a+b \sin (x)} \, dx &=-\frac {\cos (x)}{b}-\frac {\int \frac {a \sin (x)}{a+b \sin (x)} \, dx}{b}\\ &=-\frac {\cos (x)}{b}-\frac {a \int \frac {\sin (x)}{a+b \sin (x)} \, dx}{b}\\ &=-\frac {a x}{b^2}-\frac {\cos (x)}{b}+\frac {a^2 \int \frac {1}{a+b \sin (x)} \, dx}{b^2}\\ &=-\frac {a x}{b^2}-\frac {\cos (x)}{b}+\frac {\left (2 a^2\right ) \operatorname {Subst}\left (\int \frac {1}{a+2 b x+a x^2} \, dx,x,\tan \left (\frac {x}{2}\right )\right )}{b^2}\\ &=-\frac {a x}{b^2}-\frac {\cos (x)}{b}-\frac {\left (4 a^2\right ) \operatorname {Subst}\left (\int \frac {1}{-4 \left (a^2-b^2\right )-x^2} \, dx,x,2 b+2 a \tan \left (\frac {x}{2}\right )\right )}{b^2}\\ &=-\frac {a x}{b^2}+\frac {2 a^2 \tan ^{-1}\left (\frac {b+a \tan \left (\frac {x}{2}\right )}{\sqrt {a^2-b^2}}\right )}{b^2 \sqrt {a^2-b^2}}-\frac {\cos (x)}{b}\\ \end {align*}

________________________________________________________________________________________

Mathematica [A]  time = 0.09, size = 56, normalized size = 0.92 \[ -\frac {-\frac {2 a^2 \tan ^{-1}\left (\frac {a \tan \left (\frac {x}{2}\right )+b}{\sqrt {a^2-b^2}}\right )}{\sqrt {a^2-b^2}}+a x+b \cos (x)}{b^2} \]

Antiderivative was successfully verified.

[In]

Integrate[Sin[x]^2/(a + b*Sin[x]),x]

[Out]

-((a*x - (2*a^2*ArcTan[(b + a*Tan[x/2])/Sqrt[a^2 - b^2]])/Sqrt[a^2 - b^2] + b*Cos[x])/b^2)

________________________________________________________________________________________

fricas [A]  time = 0.50, size = 231, normalized size = 3.79 \[ \left [-\frac {\sqrt {-a^{2} + b^{2}} a^{2} \log \left (\frac {{\left (2 \, a^{2} - b^{2}\right )} \cos \relax (x)^{2} - 2 \, a b \sin \relax (x) - a^{2} - b^{2} + 2 \, {\left (a \cos \relax (x) \sin \relax (x) + b \cos \relax (x)\right )} \sqrt {-a^{2} + b^{2}}}{b^{2} \cos \relax (x)^{2} - 2 \, a b \sin \relax (x) - a^{2} - b^{2}}\right ) + 2 \, {\left (a^{3} - a b^{2}\right )} x + 2 \, {\left (a^{2} b - b^{3}\right )} \cos \relax (x)}{2 \, {\left (a^{2} b^{2} - b^{4}\right )}}, -\frac {\sqrt {a^{2} - b^{2}} a^{2} \arctan \left (-\frac {a \sin \relax (x) + b}{\sqrt {a^{2} - b^{2}} \cos \relax (x)}\right ) + {\left (a^{3} - a b^{2}\right )} x + {\left (a^{2} b - b^{3}\right )} \cos \relax (x)}{a^{2} b^{2} - b^{4}}\right ] \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(sin(x)^2/(a+b*sin(x)),x, algorithm="fricas")

[Out]

[-1/2*(sqrt(-a^2 + b^2)*a^2*log(((2*a^2 - b^2)*cos(x)^2 - 2*a*b*sin(x) - a^2 - b^2 + 2*(a*cos(x)*sin(x) + b*co
s(x))*sqrt(-a^2 + b^2))/(b^2*cos(x)^2 - 2*a*b*sin(x) - a^2 - b^2)) + 2*(a^3 - a*b^2)*x + 2*(a^2*b - b^3)*cos(x
))/(a^2*b^2 - b^4), -(sqrt(a^2 - b^2)*a^2*arctan(-(a*sin(x) + b)/(sqrt(a^2 - b^2)*cos(x))) + (a^3 - a*b^2)*x +
 (a^2*b - b^3)*cos(x))/(a^2*b^2 - b^4)]

________________________________________________________________________________________

giac [A]  time = 0.36, size = 77, normalized size = 1.26 \[ \frac {2 \, {\left (\pi \left \lfloor \frac {x}{2 \, \pi } + \frac {1}{2} \right \rfloor \mathrm {sgn}\relax (a) + \arctan \left (\frac {a \tan \left (\frac {1}{2} \, x\right ) + b}{\sqrt {a^{2} - b^{2}}}\right )\right )} a^{2}}{\sqrt {a^{2} - b^{2}} b^{2}} - \frac {a x}{b^{2}} - \frac {2}{{\left (\tan \left (\frac {1}{2} \, x\right )^{2} + 1\right )} b} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(sin(x)^2/(a+b*sin(x)),x, algorithm="giac")

[Out]

2*(pi*floor(1/2*x/pi + 1/2)*sgn(a) + arctan((a*tan(1/2*x) + b)/sqrt(a^2 - b^2)))*a^2/(sqrt(a^2 - b^2)*b^2) - a
*x/b^2 - 2/((tan(1/2*x)^2 + 1)*b)

________________________________________________________________________________________

maple [A]  time = 0.07, size = 72, normalized size = 1.18 \[ -\frac {2}{b \left (\tan ^{2}\left (\frac {x}{2}\right )+1\right )}-\frac {2 \arctan \left (\tan \left (\frac {x}{2}\right )\right ) a}{b^{2}}+\frac {2 a^{2} \arctan \left (\frac {2 a \tan \left (\frac {x}{2}\right )+2 b}{2 \sqrt {a^{2}-b^{2}}}\right )}{b^{2} \sqrt {a^{2}-b^{2}}} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(sin(x)^2/(a+b*sin(x)),x)

[Out]

-2/b/(tan(1/2*x)^2+1)-2/b^2*arctan(tan(1/2*x))*a+2*a^2/b^2/(a^2-b^2)^(1/2)*arctan(1/2*(2*a*tan(1/2*x)+2*b)/(a^
2-b^2)^(1/2))

________________________________________________________________________________________

maxima [F(-2)]  time = 0.00, size = 0, normalized size = 0.00 \[ \text {Exception raised: ValueError} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(sin(x)^2/(a+b*sin(x)),x, algorithm="maxima")

[Out]

Exception raised: ValueError >> Computation failed since Maxima requested additional constraints; using the 'a
ssume' command before evaluation *may* help (example of legal syntax is 'assume(4*b^2-4*a^2>0)', see `assume?`
 for more details)Is 4*b^2-4*a^2 positive or negative?

________________________________________________________________________________________

mupad [B]  time = 6.91, size = 623, normalized size = 10.21 \[ -\frac {2}{b\,\left ({\mathrm {tan}\left (\frac {x}{2}\right )}^2+1\right )}-\frac {a\,x}{b^2}-\frac {a^2\,\mathrm {atan}\left (\frac {\frac {a^2\,\left (\frac {32\,a^4}{b}-\frac {32\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (2\,a^5\,b-2\,a^3\,b^3\right )}{b^3}+\frac {a^2\,\left (32\,a^2\,b^2+64\,a^3\,b\,\mathrm {tan}\left (\frac {x}{2}\right )+\frac {a^2\,\left (32\,a^2\,b^3+\frac {32\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (3\,a\,b^7-2\,a^3\,b^5\right )}{b^3}\right )}{b^2\,\sqrt {b^2-a^2}}\right )}{b^2\,\sqrt {b^2-a^2}}\right )\,1{}\mathrm {i}}{b^2\,\sqrt {b^2-a^2}}-\frac {a^2\,\left (\frac {32\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (2\,a^5\,b-2\,a^3\,b^3\right )}{b^3}-\frac {32\,a^4}{b}+\frac {a^2\,\left (32\,a^2\,b^2+64\,a^3\,b\,\mathrm {tan}\left (\frac {x}{2}\right )-\frac {a^2\,\left (32\,a^2\,b^3+\frac {32\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (3\,a\,b^7-2\,a^3\,b^5\right )}{b^3}\right )}{b^2\,\sqrt {b^2-a^2}}\right )}{b^2\,\sqrt {b^2-a^2}}\right )\,1{}\mathrm {i}}{b^2\,\sqrt {b^2-a^2}}}{\frac {128\,a^5\,\mathrm {tan}\left (\frac {x}{2}\right )}{b^3}+\frac {a^2\,\left (\frac {32\,a^4}{b}-\frac {32\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (2\,a^5\,b-2\,a^3\,b^3\right )}{b^3}+\frac {a^2\,\left (32\,a^2\,b^2+64\,a^3\,b\,\mathrm {tan}\left (\frac {x}{2}\right )+\frac {a^2\,\left (32\,a^2\,b^3+\frac {32\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (3\,a\,b^7-2\,a^3\,b^5\right )}{b^3}\right )}{b^2\,\sqrt {b^2-a^2}}\right )}{b^2\,\sqrt {b^2-a^2}}\right )}{b^2\,\sqrt {b^2-a^2}}+\frac {a^2\,\left (\frac {32\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (2\,a^5\,b-2\,a^3\,b^3\right )}{b^3}-\frac {32\,a^4}{b}+\frac {a^2\,\left (32\,a^2\,b^2+64\,a^3\,b\,\mathrm {tan}\left (\frac {x}{2}\right )-\frac {a^2\,\left (32\,a^2\,b^3+\frac {32\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (3\,a\,b^7-2\,a^3\,b^5\right )}{b^3}\right )}{b^2\,\sqrt {b^2-a^2}}\right )}{b^2\,\sqrt {b^2-a^2}}\right )}{b^2\,\sqrt {b^2-a^2}}}\right )\,2{}\mathrm {i}}{b^2\,\sqrt {b^2-a^2}} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(sin(x)^2/(a + b*sin(x)),x)

[Out]

- 2/(b*(tan(x/2)^2 + 1)) - (a*x)/b^2 - (a^2*atan(((a^2*((32*a^4)/b - (32*tan(x/2)*(2*a^5*b - 2*a^3*b^3))/b^3 +
 (a^2*(32*a^2*b^2 + 64*a^3*b*tan(x/2) + (a^2*(32*a^2*b^3 + (32*tan(x/2)*(3*a*b^7 - 2*a^3*b^5))/b^3))/(b^2*(b^2
 - a^2)^(1/2))))/(b^2*(b^2 - a^2)^(1/2)))*1i)/(b^2*(b^2 - a^2)^(1/2)) - (a^2*((32*tan(x/2)*(2*a^5*b - 2*a^3*b^
3))/b^3 - (32*a^4)/b + (a^2*(32*a^2*b^2 + 64*a^3*b*tan(x/2) - (a^2*(32*a^2*b^3 + (32*tan(x/2)*(3*a*b^7 - 2*a^3
*b^5))/b^3))/(b^2*(b^2 - a^2)^(1/2))))/(b^2*(b^2 - a^2)^(1/2)))*1i)/(b^2*(b^2 - a^2)^(1/2)))/((128*a^5*tan(x/2
))/b^3 + (a^2*((32*a^4)/b - (32*tan(x/2)*(2*a^5*b - 2*a^3*b^3))/b^3 + (a^2*(32*a^2*b^2 + 64*a^3*b*tan(x/2) + (
a^2*(32*a^2*b^3 + (32*tan(x/2)*(3*a*b^7 - 2*a^3*b^5))/b^3))/(b^2*(b^2 - a^2)^(1/2))))/(b^2*(b^2 - a^2)^(1/2)))
)/(b^2*(b^2 - a^2)^(1/2)) + (a^2*((32*tan(x/2)*(2*a^5*b - 2*a^3*b^3))/b^3 - (32*a^4)/b + (a^2*(32*a^2*b^2 + 64
*a^3*b*tan(x/2) - (a^2*(32*a^2*b^3 + (32*tan(x/2)*(3*a*b^7 - 2*a^3*b^5))/b^3))/(b^2*(b^2 - a^2)^(1/2))))/(b^2*
(b^2 - a^2)^(1/2))))/(b^2*(b^2 - a^2)^(1/2))))*2i)/(b^2*(b^2 - a^2)^(1/2))

________________________________________________________________________________________

sympy [F(-1)]  time = 0.00, size = 0, normalized size = 0.00 \[ \text {Timed out} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(sin(x)**2/(a+b*sin(x)),x)

[Out]

Timed out

________________________________________________________________________________________